Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Typst Language Support #302

Open
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

grantlemons
Copy link
Contributor

@grantlemons grantlemons commented Dec 4, 2024

Re-opening of #289 from my fork instead of a branch

@grantlemons
Copy link
Contributor Author

grantlemons commented Dec 18, 2024

Mostly just needs more tests. I'm no expert in Typst syntax, so if someone wants to help it would be much appreciated.

@Andrew15-5
Copy link

If I can understand the core concepts mentioned above (what should/could be checked), then I maybe be able to add some tests.

- Only consolidate adjacent space spans
- Typst spaces distinguish between newlines and spaces
- Typst spaces count number of spaces
- Spans command now defaults to not show newlines
- Remove unneeded &mut impl Parser in document
Copy link
Collaborator

@elijah-potter elijah-potter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I have some questions.

harper-cli/src/main.rs Outdated Show resolved Hide resolved
harper-tree-sitter/src/lib.rs Show resolved Hide resolved
@@ -24,6 +24,7 @@ thiserror = "2.0.9"
unicode-blocks = "0.1.9"
unicode-width = "0.2.0"
levenshtein_automata = { version = "0.2.1", features = ["fst_automaton"] }
typst-syntax = "0.12.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typst is pretty big and completely unused for certain applications (i.e. Obsidian). Would you mind putting Typst support behind a feature flag?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could make the Typst parser its own crate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would making it a seperate crate help? It would still be a dependency...

I feel like feature flag is the way to go. I assume we would have it enabled for harper-ls and harper-cli?

Copy link
Collaborator

@elijah-potter elijah-potter Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple reasons.

The intention is eventually, and especially with harper-tree-sitter, that Parsers may become a community endeavor. They should be able to be built without great understanding of Harper internals. Such parsers should be able to stand on their own without official support from me or Automattic.

If people build applications (other than harper-ls) using Harper, they should be able to build and pull in third-party parsers as they need. Having many parsers in harper-core sets the expectation that all parsers must be officially supported and maintained by us.

Eventually, I hope this to be true for Linters as well, but that's a little ways off.

In fact, if you wish to move the Typst Parser to its own repository and make this PR simply import it, I find that most appealing.

harper-core/src/mask/mod.rs Show resolved Hide resolved
This reverts part of commit b61c78c.
The portion reverted is the default hiding of newlines in the span
command, which has been relocated to a new branch
@grantlemons
Copy link
Contributor Author

I decided to move typst parsing into its own crate, since it simplifies the feature dependency and establishes good precident that can be followed for unofficial/external parsers in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants